package com.fairytask.layer
{
	import flash.display.Sprite;
	/**
	 * 界面显示 
	 * @author game
	 * 
	 */	
	public class UILayer extends Sprite
	{
		private var bottomSpace	:Sprite;
		private var middleSpace	:Sprite;
		private var topSpace		:Sprite;
		private var loadSpace		:Sprite;
		public function UILayer()
		{
			super();
		}
		
		/**
		 * 添加中间层 
		 * @param pUI
		 * @param isOnly
		 * 
		 */
		public function addMid(pUI:Sprite,isOnly:Boolean=true):void
		{
			if(isOnly)
			{
				while(middleSpace.numChildren>0)
				{
					middleSpace.removeChildAt(0);
				}
			}
			middleSpace.addChild(pUI);
		}
		
		/**
		 * 添加上层UI 
		 * @param pUI
		 * @param pIdx
		 * 
		 */
		public function addTop(pUI:Sprite,pIdx:int=-1):void
		{
			if(pIdx>-1)
			{
				topSpace.addChildAt(pUI,pIdx);
			}
			else
			{
				topSpace.addChild(pUI);
			}
		}
		/**
		 * 添加下层UI 
		 * @param pUI
		 * @param pIdx
		 * 
		 */
		public function addBottom(pUI:Sprite,pIdx:int=-1):void
		{
			if(pIdx>-1)
			{
				bottomSpace.addChildAt(pUI,pIdx);
			}
			else
			{
				bottomSpace.addChild(pUI);
			}
		}
		/**
		 * 添加加载层UI 
		 * @param pUI
		 * @param pIdx
		 * 
		 */
		public function addLoader(pUI:Sprite,pIdx:int=-1):void
		{
			if(pIdx>-1)
			{
				loadSpace.addChildAt(pUI,pIdx);
			}
			else
			{
				loadSpace.addChild(pUI);
			}
		}
	}
}